<div class="layui-fluid">
  <div class="layui-row">
    <form action="" method="post" class="layui-form layui-form-pane">
      <div class="layui-form-item">
        <label for="properyt_name" class="layui-form-label">
          <span class="x-red">*</span>房产
        </label>
        <div class="layui-input-inline">
          <input type="text" id="properyt_name" name="properyt_name" value="{$data.properyt_name}" required=""
            lay-verify="required" autocomplete="off" class="layui-input" readonly style="background-color: #eeeeee;">
        </div>
      </div>
      <div class="layui-form-item">
        {if $data.id}
        <label for="house_number_name" class="layui-form-label">
          <span class="x-red">*</span>房号
        </label>
        <div class="layui-input-inline">
          <input type="text" id="house_number_name" name="house_number_name" value="{$data.house_number_name}"
            required="" lay-verify="required|max32" autocomplete="off" class="layui-input" readonly
            style="background-color: #eeeeee;">
        </div>
        <input type="hidden" name="house_number_id" value="{$data.house_number_id}">
        {else}
        <label for="house_number_id" class="layui-form-label">
          <span class="x-red">*</span>房号
        </label>
        <div class="layui-input-inline">
          <select name="house_number_id">
            {foreach $number_data as $v}
            <option value="{$v.id}">{$v.name}</option>
            {/foreach}
          </select>
        </div>
        {/if}
      </div>
      <div class="layui-form-item">
        <label for="start_time" class="layui-form-label">
          <span class="x-red">*</span>日期
        </label>
        <div class="layui-input-inline">
          <input type="text" class="layui-input" id="start_time" name="start_time"
            value="{$data.start_time|default=time()|date='Y-m-d'}" required="" lay-verify="required" autocomplete="off">
        </div>
      </div>
      <div class="layui-form-item">
        <label for="other_charges" class="layui-form-label">
          <span class="x-red">*</span>其他费用
        </label>
        <div class="layui-input-inline">
          <input type="text" id="other_charges" name="other_charges" value="{$data.other_charges}" required=""
            lay-verify="required|number" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item layui-form-text">
        <label for="note" class="layui-form-label">备注</label>
        <div class="layui-input-block">
          <textarea id="note" name="note" lay-verify="max255" class="layui-textarea">{$data.note}</textarea>
        </div>
      </div>
      <div class="layui-form-item">
        <input type="hidden" name="house_property_id" value="{$data.house_property_id}">
        <input type="hidden" name="id" value="{$data.id}">
        <button class="layui-btn" lay-submit="" lay-filter="save">保存</button>
      </div>
    </form>
  </div>
</div>

<script>
  layui.use(['form', 'layer', 'laydate'], function () {
    $ = layui.jquery;
    var form = layui.form
      , laydate = layui.laydate
      , layer = layui.layer;

    //执行一个laydate实例
    laydate.render({
      elem: '#start_time' //指定元素
    });

    //监听提交
    form.on('submit(save)', function (data) {
      //发异步，把数据提交给php
      main.ajaxPost(
        {
          url: "{:url('saveBill')}",
          data: data.field,
        },
        function (data) {
          setTimeout(function () {
            // 获得frame索引
            var index = parent.layer.getFrameIndex(window.name);
            //表格重载
            parent.layui.table.reload('dataGrid');
            //关闭当前frame 
            parent.layer.close(index);
          }, 1000);
        }
      )
      return false;
    });
  });
</script>